package com.cloud.security.controller;

import com.cloud.common.domain.Result;
import com.cloud.controller.BaseController;
import com.cloud.security.service.IProfileUserService;
import com.cloud.user_info.entity.vo.ProfileDept;
import com.cloud.user_info.entity.vo.ProfileUser;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "授权用户信息")
@RestController
@RequestMapping("/security/profile")
public class ProfileUserController extends BaseController {

    @Autowired
    private IProfileUserService profileUserService;

    @Operation(summary = "获取授权用户信息(header传参)")
    @GetMapping(value = "/getAuthUser")
    public Result getAuthUser() {
        return profileUserService.getAuthUserInfo();
    }

    @Operation(summary = "获取系统用户列表")
    @GetMapping("/getUserList")
    public Result getUserList(ProfileUser user) {
        startPage();
        List<ProfileUser> userList = profileUserService.getUserList(user);
        return getDataTable(userList);
    }

    @Operation(summary = "获取系统用户信息")
    @GetMapping("/getUserInfo")
    public Result getUserInfo(ProfileUser user) {
        return profileUserService.getUserInfo(user);
    }

    @Operation(summary = "获取系统部门列表")
    @GetMapping("/getDeptList")
    public Result getDeptList(ProfileDept dept) {
        startPage();
        List<ProfileDept> deptList = profileUserService.getDeptList(dept);
        return getDataTable(deptList);
    }

    @Operation(summary = "获取系统部门信息")
    @GetMapping("/getDeptInfo")
    public Result getDeptInfo(ProfileDept dept) {
        return profileUserService.getDeptInfo(dept);
    }

}
